const Tips = (title) => {
	uni.showToast({
		title: title,
		duration: 2000,
		icon: 'none'
	})
}
// const baseURL = "https://huijiank.com";
// const baseURL = "https://ceshi.huijiank.com/";
const baseURL = "http://hjk.com/"
// http://192.168.1.11:8081
// http://127.0.0.1:4523

export default async function request(params) {
	return new Promise((reslove, reject) => {
		if (params.loading) uni.showLoading();

		uni.request({
			url: baseURL + params.url,
			method: params.method,
			header: {
				'Content-Type': 'application/json',
				'token': uni.getStorageSync('token1')
			},
			data: params.data,
			complete: (weq) => {
				if (params.loading) uni.hideLoading();
			},
			success: (res) => {
				if (res.data.code == 1) {
					reslove(res.data);
				} else if (res.data.code == 401) {
					uni.reLaunch({
						url: '/pages/subpackage/landing_operation/logIn'
					})
				} else if (res.data.code == 0) {
					reslove(res.data);
					uni.showToast({
					    title: res.data.msg,
					    icon: "none",
					    duration: 2000,
					});
				}
			},
			fail: (err) => {
				return Tips('连接失败，请稍后再试！');
			}
		})
	})
}